﻿<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Keywords>
        <Keyword>
        </Keyword>
      </Keywords>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>ParseTypeName</Title>
      <Author>innovoCAD</Author>
      <Description>Parse type name into MSElementType[].</Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>MSCEParseTypeName</Shortcut>
    </Header>
    <Snippet>
      <Imports>
        <Import>
          <Namespace>BDPN = Bentley.DgnPlatformNET</Namespace>
        </Import>
        <Import>
          <Namespace>System</Namespace>
        </Import>
        <Import>
          <Namespace>System.Collections.Generic</Namespace>
        </Import>
      </Imports>
      <References>
        <Reference>
          <Assembly>Bentley.DgnPlatformNET</Assembly>
        </Reference>
      </References>
      <Declarations>
      </Declarations>
      <Code Language="csharp" Kind="method decl" Delimiter="$"><![CDATA[
/// <summary>
/// Parse type name (e.g. 'line') into MSElementType[] 
/// </summary>
/// <param name="unParsedTypeName"></param>
/// <returns></returns>
BDPN.MSElementType[] ParseTypeName(string unParsedTypeName)
{
    //TODO: Modify or add to list.
    List<BDPN.MSElementType> typeNameList = new List<BDPN.MSElementType>();            
    string[] parseTypeName = unParsedTypeName.Split(new Char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
    foreach (var typeName in parseTypeName)
    {
        BDPN.MSElementType elemType = BDPN.MSElementType.None;
        switch (typeName.Trim().ToLower())
        {
            case "cell":
                elemType = BDPN.MSElementType.CellHeader;
                break;
            case "shared":
            case "sharedcell":
                elemType = BDPN.MSElementType.SharedCellInstance;
                break;
            case "line":
            case "lines":
                elemType = BDPN.MSElementType.Line;
                break;
            case "lstring":
            case "linestring":
                elemType = BDPN.MSElementType.LineString;
                break;
            case "arc":
                elemType = BDPN.MSElementType.Arc;
                break;
            case "circle":
            case "ellipse":
                elemType = BDPN.MSElementType.Ellipse;
                break;
            case "polygon":
            case "shape":
                elemType = BDPN.MSElementType.Shape;
                break;
            case "tag":
            case "tags":
                elemType = BDPN.MSElementType.Tag;
                break;
            case "text":
                elemType = BDPN.MSElementType.Text;
                break;
            case "node":
            case "textnode":
                elemType = BDPN.MSElementType.TextNode;
                break;                    
        }
        typeNameList.Add(elemType);
    }

    return typeNameList.ToArray();
}]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>